<?php
/**
* @project ApPHP Medical Appointment
* @copyright (c) 2012 ApPHP
* @author ApPHP <info@apphp.com>
* @license http://www.gnu.org/licenses/
*/

// *** Make sure the file isn't accessed directly
defined('APPHP_EXEC') or die('Restricted Access');
//--------------------------------------------------------------------------

if($objLogin->IsLoggedInAsPatient() && Modules::IsModuleInstalled('appointments') && ModulesSettings::Get('appointments', 'is_active') == 'yes'){

	$task = isset($_POST['task']) ? prepare_input($_POST['task']) : '';

	$params = array();
	$params['docid']	   = isset($_POST['docid']) ? prepare_input($_POST['docid']) : '';
	$params['schid'] 	   = isset($_POST['schid']) ? prepare_input($_POST['schid']) : '';
	$params['date'] 	   = isset($_POST['date']) ? prepare_input($_POST['date']) : '';
	$params['start_time']  = isset($_POST['start_time']) ? prepare_input($_POST['start_time']) : '';
	$params['duration']    = isset($_POST['duration']) ? prepare_input($_POST['duration']) : '';
	$params['dspecid']     = isset($_POST['dspecid']) ? prepare_input($_POST['dspecid']) : '';
	$params['for_whom']    = isset($_POST['for_whom']) ? prepare_input($_POST['for_whom']) : '';

	$appointment_details = &$_SESSION['appointment_details'];
	
	if(empty($task)){
		if(!empty($appointment_details)){
			$task 				   = 'verify_appointment';
			$params['docid']	   = isset($appointment_details['docid']) ? prepare_input($appointment_details['docid']) : '';
			$params['schid'] 	   = isset($appointment_details['schid']) ? prepare_input($appointment_details['schid']) : '';
			$params['date'] 	   = isset($appointment_details['date']) ? prepare_input($appointment_details['date']) : '';
			$params['start_time']  = isset($appointment_details['start_time']) ? prepare_input($appointment_details['start_time']) : '';
			$params['duration']    = isset($appointment_details['duration']) ? prepare_input($appointment_details['duration']) : '';
			$params['dspecid']     = isset($appointment_details['dspecid']) ? prepare_input($appointment_details['dspecid']) : '';
			$params['for_whom']    = isset($appointment_details['for_whom']) ? prepare_input($appointment_details['for_whom']) : '';
		}else{
			if($objLogin->IsLoggedInAsPatient()){
				header('location: index.php?patient=home');
				exit;
			}			
		}
	}
	$appointment_details = array();
	
}
	
?>